#ifndef HPLCTIMEPROGRAMUNIT_H
#define HPLCTIMEPROGRAMUNIT_H

#include <QObject>
#include "hplctimeprogramdefine.h"

class HplcTimeProgramUnit : public QObject
{
    Q_OBJECT
public:

    explicit HplcTimeProgramUnit(QObject *parent = nullptr);

    void setTickPeriod(double period);

    void reset();

    void setUnit(PumpUnit unit);
    void setNextUnit(PumpUnit unit);
    PumpUnit getCurrent() const;
    double getProgress() const;


    bool isFinished() const;

    void calculateDelta();
    void calculate();

public slots:
    void onTick();

signals:

private:
    double              m_tickPeriod = 0.5; // s

    PumpUnit            m_unit;
    PumpUnit            m_nextUnit;
    PumpUnit            m_delta;

    PumpUnit            m_current;

    double              m_progress; // 当前进度 [0.0~1.0]
};

#endif // HPLCTIMEPROGRAMUNIT_H
